<template>
	<view>
		<u-navbar :border-bottom="false" title="采购设置" :title-size="36" :title-bold="true" :title-color="textColor" :background="{backgroudColor: bgColor}" @customBack="goBack()">
		</u-navbar>
		<view class="u-m-b-20">
			<u-cell-group :title-style="titleStyle" :border="false">
				<u-cell-item title="企业名称" :value="shopName" :arrow="false">
					<view slot="right-icon" ><u-icon name="arrow-right" :size="35" color="#FFFFFF"></u-icon></view>
				</u-cell-item>
				<u-cell-item title="营业执照" :value="businessLicenseResourceId ? '已上传':'未上传'" :arrow="false" @click="previewImg">
					<view slot="right-icon" ><u-icon name="arrow-right" :size="35" color="#FFFFFF"></u-icon></view>
				</u-cell-item>
			<!-- 	<u-cell-item title="企业级别" :value="shopLevels[0].name+(shopLevels.length!=0?'...':'')" :arrow="false">
					<view slot="right-icon" ><u-icon name="arrow-right" :size="35" color="#FFFFFF"></u-icon></view>
				</u-cell-item> -->
			</u-cell-group>
		</view>
		<view class="u-m-b-20" >
			<u-cell-group :title-style="titleStyle" :border="false">
				<u-cell-item title="企业图标" value="修改图标" @tap="toPage('touxiang')"></u-cell-item>
				<u-cell-item title="发票" :value="shopInvoiceConfigsName!=null ? shopInvoiceConfigsName:'请配置发票信息'" :border-bottom="false" @click="toPage('fapiao')"></u-cell-item>
				<u-cell-item title="收货地址" :value="deliveryAddressesName!=null ? deliveryAddressesName:'请配置地址信息'" @click="toPage('dizhi')"></u-cell-item>
				<u-cell-item title="职位管理" value="设置企业职位" @click="toPage('zhiwei')"></u-cell-item>
				<u-cell-item title="员工管理" value="管理企业员工" @click="toPage('yuangong')"></u-cell-item>
			</u-cell-group>
		</view>
		<view class="u-m-b-20" >
			<u-cell-group :title-style="titleStyle" :border="false">
				<u-cell-item title="企业注销" :border-bottom="false" @click="toKefu"></u-cell-item>
				<!-- <u-cell-item title="企业转移" :border-bottom="false"></u-cell-item> -->
			</u-cell-group>
		</view>
		<akLoading isFullScreen :active="loading"></akLoading>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				titleStyle: {
					fontSize: '30rpx',
				},
				shopId:'',
				loading:false,
				deliveryAddressesName:null,
				shopInvoiceConfigsName:null,
				businessLicenseResourceId:null,
				shopName:'',
				shopLevelName:'',
				shopLevels:[
					{
						name:''
					}
				],
				avatar:'',
			}
		},
		onLoad(options) {
			this.shopId = options.id;
			this.type = options.type;
		},
		computed: {
			// invoice() {
			// 	if(this.$store.state.shop.shop.shopInvoiceConfigs.length == 0) {
			// 		return '请配置发票信息'
			// 	} else {
			// 		return this.$store.state.shop.shop.shopInvoiceConfigs[0].name
			// 	}
			// },
			// address() {
			// 	if(this.$store.state.shop.shop.deliveryAddresses.length == 0) {
			// 		return '请配置地址信息'
			// 	} else {
			// 		return this.$store.state.shop.shop.deliveryAddresses[0].name+'，'+this.$store.state.shop.shop.deliveryAddresses[0].phoneNumber
			// 	}
			// }
		},
		onShow() {
			this.shopInfoInitFn();
		},
		created() {
			// this.shopInfoInitFn();
		},
		methods: {
			toPage(page) {
				let avatar = '';
				if(page == 'touxiang'){
					avatar = '&avatar='+ this.avatar;
				}
				this.$mRouter.push({
					route: '/pages/purchase/shezhi/' + page+'?shopId='+this.shopId+avatar
				})
			},
			async shopInfoInitFn(){
				this.loading = true;
				const res = await this.$newHttp.get('api/Shop/GetShop?id='+this.shopId);
				this.loading = false;
				if(res.code === 200){
					this.shopName = res.data.name;
					this.businessLicenseResourceId = res.data.businessLicenseUrl;
					if(res.data.deliveryAddresses.length!==0){
						this.deliveryAddressesName = res.data.deliveryAddresses[0].name;
					}
					if(res.data.shopInvoiceConfigs.length!==0){
						this.shopInvoiceConfigsName = res.data.shopInvoiceConfigs[0].name;
					}
					if(res.data.shopLevels!=null){
						this.shopLevels = res.data.shopLevels;
					}
					// this.avatar=this.resourcesUrl+(res.data.logoResourceId==null?'00000000-0000-0000-0000-000000000002':res.data.logoResourceId);
					this.avatar=res.data.logoUrl?res.data.logoUrl:this.defaultLogo;
				}else{
					this.$u.toast('获取企业信息失败，请退出重试')
				}
			},
			previewImg() {
				if (this.businessLicenseResourceId== null) return false;
				const imageArr = [this.businessLicenseResourceId]
				uni.previewImage({
					urls: imageArr
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
</style>
